#ifndef CAMWRAPPER_H
#define CAMWRAPPER_H

#include "CameraDetails.h"
#include "CameraInterfaceBase.h"
#include <stdlib.h>
#include <opencv/cxcore.h>

//class AvtGigE;
//class AvtUniAPI;
//class OpenCvHighGui;

class CamWrapper {
public:
	CamWrapper();
	CamWrapper(CAM_INTERFACE_TYPE iface);
	~CamWrapper();
	bool initInterface();
	bool initInterface(CAM_INTERFACE_TYPE iface);
    bool probeCam(unsigned int &numFound);
	bool getCamId(int index, unsigned long &camId, std::string *camName = NULL);
	bool openCam(unsigned long camId);
	bool isOpened();
	bool isInitialised();
	//bool setCamName(std::string camName);
	bool getCamProperties(unsigned long propId, unsigned long &value);
	bool setCamProperties(unsigned long propId, unsigned long value);
	bool getCamProperties(unsigned long propId, double &value);
	bool setCamProperties(unsigned long propId, double value);
	bool getCamProperties(char *propId, unsigned long &value);
	bool setCamProperties(char *propId, unsigned long value);
	bool setImageSize(unsigned int width, unsigned int height, unsigned int bytesPerChannel, unsigned int channels);
	IplImage* grabDemosaicingImage(DEMOSAICING_TYPE demosaicingMethod = DEMOSAICING_TYPE_END, CFA_TYPE cfaType = CFA_TYPE_END);
	IplImage* grabRawImage();
	bool setVerbose(bool isVerbose);
	bool closeCam();
	bool releaseInterface();
	unsigned long getCurrentCamID();
private:
	void text(std::string message, bool error = false);
	void deInteraceImage(char *dataSource, char *dataDist, int width, int height, int srcWidthStep, int dstWidthStep); 
	CAM_INTERFACE_TYPE camInterface;
	unsigned long camUniqueId;
	bool opened;
	CameraInterface *targetCam;
	//AvtGigE *avtGigEcam;
	//AvtUniAPI *avtUniApiCam;
	//OpenCvHighGui *highGuiCam;
	//std::vector<CameraDetails> camList;
	bool verbose;
	bool initialised;
	IplImage *rgbImage;
};

#endif
